import pymysql
try:
    connect = pymysql.connect(host = "127.0.0.1",
                              user="root",
                              password="admin",
                              db="spider",
                              charset="utf8")
    cursor = connect.cursor()
    sql="insert into teacherinfo(tno,tname,remark)values('240101','何凤','上的牛逼')"
    cursor.execute(sql)
    connect.commit()
except Exception as e:
    connect.rollback()
    print(e)
finally:
    cursor.close()
    connect.close()